package org.keyyond.ms.scheduler.service.impl;

import org.keyyond.ms.core.util.HttpUtil;
import org.keyyond.ms.scheduler.service.MsEsbFeiYunSyncService;
import org.keyyond.ms.scheduler.util.EncryptUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

@Service
@RefreshScope
public class MsEsbFeiYunSyncServiceImpl implements MsEsbFeiYunSyncService{
	
	@Value("${sendFyUrlOfDept}")
	private String sendFyUrlOfDept;
	
	@Value("${sendFyUrlOfUser}")
	private String sendFyUrlOfUser;
	
	@Value("${authParam}")
	private String authParam;
	
	@Value("${feiYunApp}")
	private String feiYunApp;
	
	private static Logger logger = LoggerFactory.getLogger(MsEsbFeiYunSyncServiceImpl.class);

	@Override
	public String deptSyncFeiYun() {
		// TODO Auto-generated method stub
		String param="{\"relationApp\":\""+feiYunApp+"\"}";
		String encrypt = EncryptUtil.encrypt2(authParam,param);
		String result=null;
		if(encrypt!=null){
			result=HttpUtil.sendPost(sendFyUrlOfDept, encrypt, "UTF-8");
		}else{
			logger.info("加密异常！");
		}
		return result;
	}

	@Override
	public String userSyncFeiYun() {
		// TODO Auto-generated method stub
		String param="{\"relationApp\":\""+feiYunApp+"\"}";
		String encrypt = EncryptUtil.encrypt2(authParam,param);
		String result=null;
		if(encrypt!=null){
			result=HttpUtil.sendPost(sendFyUrlOfUser, encrypt, "UTF-8");
		}else{
			logger.info("加密异常！");
		}
		return result;
	}

}
